package com.xyzq.cgate.core.component.ratelimiter;

import com.google.common.util.concurrent.RateLimiter;
import lombok.NoArgsConstructor;

/**
 * @Description:
 * @author chenchen
 * @date 2019/6/26 15:35
 */
public class RateLimiterFactory {

    private static RateLimiterFactory rateLimiterFactory = new RateLimiterFactory();

    private static RateLimiter limiter = null;

    private RateLimiterFactory() {
    }

    public static RateLimiterFactory self() {
        return rateLimiterFactory;
    }

    public RateLimiter of(String permitsPerSecond) {
        limiter = RateLimiter.create(Double.parseDouble(permitsPerSecond));
        return limiter;
    }


}
